package com.ruoyi.insurance.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.insurance.domain.OutsideAttack;
import com.ruoyi.insurance.service.IOutsideAttackService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 外部攻击Controller
 * 
 * @author ruoyi
 * @date 2024-09-10
 */
@RestController
@RequestMapping("/insurance/attack")
public class OutsideAttackController extends BaseController
{
    @Autowired
    private IOutsideAttackService outsideAttackService;

    /**
     * 查询外部攻击列表
     */
    @PreAuthorize("@ss.hasPermi('insurance:attack:list')")
    @GetMapping("/list")
    public TableDataInfo list(OutsideAttack outsideAttack)
    {
        startPage();
        List<OutsideAttack> list = outsideAttackService.selectOutsideAttackList(outsideAttack);
        return getDataTable(list);
    }

    /**
     * 导出外部攻击列表
     */
    @PreAuthorize("@ss.hasPermi('insurance:attack:export')")
    @Log(title = "外部攻击", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, OutsideAttack outsideAttack)
    {
        List<OutsideAttack> list = outsideAttackService.selectOutsideAttackList(outsideAttack);
        ExcelUtil<OutsideAttack> util = new ExcelUtil<OutsideAttack>(OutsideAttack.class);
        util.exportExcel(response, list, "外部攻击数据");
    }

    /**
     * 获取外部攻击详细信息
     */
    @PreAuthorize("@ss.hasPermi('insurance:attack:query')")
    @GetMapping(value = "/{attackId}")
    public AjaxResult getInfo(@PathVariable("attackId") Long attackId)
    {
        return success(outsideAttackService.selectOutsideAttackByAttackId(attackId));
    }

    /**
     * 新增外部攻击
     */
    @PreAuthorize("@ss.hasPermi('insurance:attack:add')")
    @Log(title = "外部攻击", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody OutsideAttack outsideAttack)
    {
        return toAjax(outsideAttackService.insertOutsideAttack(outsideAttack));
    }

    /**
     * 修改外部攻击
     */
    @PreAuthorize("@ss.hasPermi('insurance:attack:edit')")
    @Log(title = "外部攻击", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody OutsideAttack outsideAttack)
    {
        return toAjax(outsideAttackService.updateOutsideAttack(outsideAttack));
    }

    /**
     * 删除外部攻击
     */
    @PreAuthorize("@ss.hasPermi('insurance:attack:remove')")
    @Log(title = "外部攻击", businessType = BusinessType.DELETE)
	@DeleteMapping("/{attackIds}")
    public AjaxResult remove(@PathVariable Long[] attackIds)
    {
        return toAjax(outsideAttackService.deleteOutsideAttackByAttackIds(attackIds));
    }
}
